<?php if(!class_exists('raintpl')){exit;}?><?php if( $user['level_name']=='officer' ){ ?>
<form action = "standard-add.php" method = "post">
<?php } ?>
<?php if( $user['level_name']=='assessor' ){ ?>
<form action = "standard-update.php" method = "post" enctype='multipart/form-data'>
<?php } ?>
<input type = "hidden" name = "id" value = "<?php echo $assessment['id'];?>">
<table class = "list">
	<tr>
		<th class = "w20">ข้อ</th>
		<?php if( $user['level_name'] == 'officer' ){ ?>
		<th class = "w150">เกณฑ์มาตรฐาน</th>
		<th class = "w150">ผลการดำเนินงาน</th>
		<th class = "w100">หลักฐาน</th>
		<th class = "w30">ลบ</th>
		<?php }else{ ?>
		<th class = "w180">เกณฑ์มาตรฐาน</th>
		<th class = "w180">ผลการดำเนินงาน</th>
		<th class = "w100">หลักฐาน</th>
		<?php } ?>
	</tr>
	<?php $counter1=-1; if( isset($standard) && is_array($standard) && sizeof($standard) ) foreach( $standard as $key1 => $value1 ){ $counter1++; ?>
	<tr>
		<td><?php echo $key1+1;?>.)</td>
		<?php if( $user['level_name']=='officer' ){ ?>
			<td><textarea name = "standard[<?php echo $value1["id"];?>]" class = "col3"><?php echo $value1["name"];?></textarea></td>
		<?php }else{ ?>
			<td><?php echo $value1["name"];?></td>
		<?php } ?>
		<?php if( $user['level_name']=='assessor' ){ ?>
			<td><textarea name = "name[<?php echo $value1["id"];?>]" class = "col3"><?php echo $value1["result"];?></textarea></td>
			<td>
				<? $i = 0; ?>
				<?php $counter2=-1; if( isset($upload) && is_array($upload) && sizeof($upload) ) foreach( $upload as $key2 => $value2 ){ $counter2++; ?>
					<?php if( $value2["acid"] == $value1["id"] ){ ?>
					<? $i++; ?>
					<a href = "<?php echo $value2["upload"];?>" target = "_blank"><img src="http://localhost/kpi/html/./images/filetype_icons/<?php echo $value2["icon"];?>" class = "h20"> หลักฐาน <?php echo $i;?>
					</a>
					<a href = "delete-file.php?id=<?php echo $value2["id"];?>&ref=<?php echo $assessment["id"];?>"><img src="http://localhost/kpi/html/./images/icon/delete.png" title = "ลบไฟล์"></a>
					<br>
					<?php } ?>
				<?php } ?>
				<input type = "file" name = "upload<?php echo $value1["id"];?>" class = "w70" size="2">
			</td>
		<?php }else{ ?>
			<td><?php echo $value1["result"];?></td>
			<td><?php echo $value1["related"];?></td>
			<?php if( $user['level_name'] == 'officer' ){ ?>
			<td><a href = "standard-delete.php?id=<?php echo $value1["id"];?>&aid=<?php echo $id;?>" alt = "ลบ" title = "ลบ" class = "delete"><img src="http://localhost/kpi/html/./images/icon/delete.png"></a></td>
			<?php } ?>
		<?php } ?>
	</tr>
	<?php } ?>
	<?php if( $user['level_name']=='officer' ){ ?>
	<tr>
		<td></td>
		<td><textarea name = "name"></textarea></td>
		<td></td>
		<td></td>
		<td></td>
	</tr>
	<?php } ?>
</table>

<?php if( $user['level_name']=='officer' ){ ?>
	<input type = "submit" value = "ตกลง">
<?php } ?>